package br.com.array.android.ma.view;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
import br.com.array.android.ma.R;

/**
 * Created by desenvolv04 on 09/05/2014.
 *
 */
public class PrincipalActivity extends FragmentActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.principal_activity);

        LinearLayout view = (LinearLayout) findViewById(R.id.root);
        PagesFragment pagesFragment = new PagesFragment(getSupportFragmentManager(), this);
        //pagesFragment.setFragmentPages(new EnergiaReativaView(getApplication()), new DemandaView(getApplicationContext()), new FatorPotenciaView(getApplication()));

        view.addView(pagesFragment);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_principal, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.menuPrincipal:
                AlertDialog.Builder builder = new AlertDialog.Builder(PrincipalActivity.this);
                builder.setTitle("Configurações").setMessage("view").setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                }).show();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}